#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, n2, num;
struct Line {
  int l, r, h, op;
  bool operator<(Line line) const {
    if (h != line.h) return h < line.h;
    return op > line.op;
  }
} lines[N];
int x[N];
int sum[N << 2], tag[N << 2];
void pushup(int p, int l, int r) {
  if (!tag[p]) {
    if (r == l + 1)
      sum[p] = 0;
    else
      sum[p] = sum[p << 1] + sum[p << 1 | 1];
  } else
    sum[p] = x[r] - x[l];
}
void addtag(int d, int p, int l, int r) {
  tag[p] += d;
  pushup(p, l, r);
}
void update(int L, int R, int d, int p, int l, int r) {
  if (L <= l && R >= r) {
    addtag(d, p, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  if (L < mid) update(L, R, d, p << 1, l, mid);
  if (R > mid) update(L, R, d, p << 1 | 1, mid, r);
  pushup(p, l, r);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  n2 = n * 2;
  rep(i, 1, n) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    lines[i] = Line{x1, x2, y1, 1};
    lines[i + n] = Line{x1, x2, y2, -1};
    x[i] = x1, x[i + n] = x2;
  }
  sort(x + 1, x + n2 + 1);
  num = unique(x + 1, x + n2 + 1) - x - 1;
  rep(i, 1, n2) {
    lines[i].l = lower_bound(x + 1, x + num + 1, lines[i].l) - x;
    lines[i].r = lower_bound(x + 1, x + num + 1, lines[i].r) - x;
  }
  sort(lines + 1, lines + n2 + 1);
  ll ans = 0;
  int pre = 0;
  rep(i, 1, n2) {
    ans += 1ll * (lines[i].h - pre) * sum[1];
    pre = lines[i].h;
    update(lines[i].l, lines[i].r, lines[i].op, 1, 1, num);
  }
  cout << ans;
  return 0;
}